package kaist.sep521.lego.circlebicycle;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;

public class MenuActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_menu);

		final Button run = (Button) findViewById(R.id.menu_buttonRun);
		final Button circle = (Button) findViewById(R.id.menu_buttonCircle);
		final Button result = (Button) findViewById(R.id.menu_buttonResult);
		final Button setting = (Button) findViewById(R.id.menu_buttonSetting);
		final Button manual = (Button) findViewById(R.id.menu_buttonManual);

		// Set up the user interaction to manually show or hide the system UI.
		run.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				// move to run window
				Intent intent = new Intent(getBaseContext(), RunActivity.class);
				startActivity(intent);
			}
		});

		// Set up the user interaction to manually show or hide the system UI.
		circle.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				// move to circle window
				Intent intent = new Intent(getBaseContext(),
						CircleActivity.class);
				startActivity(intent);
			}
		});

		// Set up the user interaction to manually show or hide the system UI.
		result.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {

				String group = MainActivity.myInfo.getGroup();
				String user = MainActivity.myInfo.getID();
				String url = "http://14.63.196.253/~lego/result_view.php?user=" + user + "&group=" + group;

				Intent intent = new Intent(getBaseContext(),
						ResultsActivity.class);
				intent.putExtra("url", url);
				startActivity(intent);
			}
		});

		// Set up the user interaction to manually show or hide the system UI.
		setting.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				Intent intent = new Intent(getBaseContext(),
						SettingActivity.class);
				startActivity(intent);				
			}
		});

		// Set up the user interaction to manually show or hide the system UI.
		manual.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				// move to manual window
				String url = "http://14.63.196.253/~lego/user_manual.html";

				Intent intent = new Intent(getBaseContext(),
						ManualActivity.class);
				intent.putExtra("url", url);
				startActivity(intent);

			}
		});
	}

	@Override
	protected void onDestroy() {
		// APP is killed when user select the Back-key on Menu window
		finish();
		System.exit(0);
	}
}
